﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3._3._4_匿名类型
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //var 与 new 关键字一起使用时， 可以创建匿名类型。匿名类型只是一个继承自 Object 且没有名称的类。该类的定义从初始化器中推断， 类似于隐式类型化的
            var captain = new //对象
            {
                FirstName = "James",//属性
                MiddleName = "T",//属性
                LastName = "Kirk"//属性
            };

            var doctor = new
            {
                FirstName = "Leonard",//属性
                MiddleName = string.Empty,//属性
                LastName = "McCoy"//属性
            };
            Console.WriteLine(doctor.FirstName);
            doctor = captain;

            Console.WriteLine(captain.FirstName);

            Console.WriteLine(doctor.FirstName);

            var cap = new
            {
                Person.FirstName,
                Person.MiddleName,
                Person.LastName
            };
            //Person.FirstName = "rrr";

            //Person person = new Person();
            //person.FirstName = "";

        Console.WriteLine(cap.FirstName);
            Console.ReadKey();
        }
    }
}
